package com.example.nbb.Controller;

import com.example.nbb.Service.ShopService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@CrossOrigin//跨域
@RestController//遵循RestFul
@RequestMapping("/nbb/Shop/")
public class ShopController {

    @Resource
    ShopService shopService;

    //获取当前用户的购物车
    @GetMapping("getAll")
    public String getAll(@RequestParam("userId") int userId) {
        return shopService.getAll(userId);
    }

    //删除当前购物车
    @PostMapping("deleteShop")
    public String deleteShop(@RequestParam("shopId") int shopId) {
        return shopService.deleteShop(shopId);
    }

    //新增购物车
    @PostMapping("insectShopCard")
    public String insectShopCard(@RequestParam("userId") int userId, @RequestParam("productId") int productId) {
        return shopService.insectShopCard(userId, productId);
    }

}
